﻿@namespace MatBlazor
@inherits BaseMatDomComponent

<div class="@ClassMapper.AsString()" style="@StyleMapper.AsString()" @attributes="Attributes" Id="@Id" @ref="Ref">
         @if (ChildContent != null)
         {
             <div class="@ContentClassMapper.AsString()">
                 @ChildContent
             </div>
         }
     </div>

     @code
     {

         [Parameter]
         public RenderFragment ChildContent { get; set; }

         [Parameter]
         public bool Square { get; set; }

         [Parameter]
         public bool Wide { get; set; }

         [Parameter]
         public string ContentClass { get; set; }

         [Parameter]
         public string ImageUrl { get; set; }


         ClassMapper ContentClassMapper = new ClassMapper();
         protected override async Task OnInitializedAsync()
         {
             await base.OnInitializedAsync();
             ClassMapper
                 .Add("mat-card-media")
                 .Add("mdc-card__media")
                 .If("mdc-card__media--16-9", () => Wide)
                 .If("mdc-card__media--square", () => Square);


             ContentClassMapper
                 .Add("mat-card-media-content")
                 .Add("mdc-card__media-content")
                 .Get(() => ContentClass);

             StyleMapper.GetIf(() => $"background-image: url(\"{ImageUrl}\")", () => ImageUrl != null);
         }

     }